I used an A Record to point a domain (e.g. example.com) to an IPv4, and a CNAME Record to point a subdomain (e.g. www.example.com) to the same IPv4 as the root domain
This is how it looks in Namecheap’s interface